package com.example.userlogincenter.userCenter.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 描述用户与API的对应关系
 * @TableName api_member
 */
@TableName(value ="api_member")
@Data
public class ApiMember implements Serializable {
    /**
     * 记录id
     */
    @TableId(value = "mId", type = IdType.AUTO)
    private Long mId;

    /**
     * 用户Id
     */
    @TableField(value = "memberId")
    private Long memberId;

    /**
     * apiId
     */
    @TableField(value = "apiId")
    private Long apiId;

    /**
     * 剩余使用次数
     */
    @TableField(value = "leavecount")
    private Long leavecount;

    /**
     * 是否免费
     */
    @TableField(value = "isFree")
    private Integer isFree;

    /**
     * 更新日期
     */
    @TableField(value = "updateDatetime")
    private Date updateDatetime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ApiMember other = (ApiMember) that;
        return (this.getMId() == null ? other.getMId() == null : this.getMId().equals(other.getMId()))
            && (this.getMemberId() == null ? other.getMemberId() == null : this.getMemberId().equals(other.getMemberId()))
            && (this.getApiId() == null ? other.getApiId() == null : this.getApiId().equals(other.getApiId()))
            && (this.getLeavecount() == null ? other.getLeavecount() == null : this.getLeavecount().equals(other.getLeavecount()))
            && (this.getIsFree() == null ? other.getIsFree() == null : this.getIsFree().equals(other.getIsFree()))
            && (this.getUpdateDatetime() == null ? other.getUpdateDatetime() == null : this.getUpdateDatetime().equals(other.getUpdateDatetime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.getMId() == null) ? 0 : getMId().hashCode());
        result = prime * result + ((getMemberId() == null) ? 0 : getMemberId().hashCode());
        result = prime * result + ((getApiId() == null) ? 0 : getApiId().hashCode());
        result = prime * result + ((getLeavecount() == null) ? 0 : getLeavecount().hashCode());
        result = prime * result + ((getIsFree() == null) ? 0 : getIsFree().hashCode());
        result = prime * result + ((getUpdateDatetime() == null) ? 0 : getUpdateDatetime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() +
                " [" +
                "Hash = " + hashCode() +
                ", mId=" + mId +
                ", memberId=" + memberId +
                ", apiId=" + apiId +
                ", leavecount=" + leavecount +
                ", isFree=" + isFree +
                ", updateDatetime=" + updateDatetime +
                ", serialVersionUID=" + serialVersionUID +
                "]";
    }
}